Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

WCA Live Result Admin #1: Submit and Updating Results #10776

Merged
merged 25 commits into from
Feb 12, 2025

Conversation

FinnIckler
Copy link
Member

Simple Submitting/Updating Results and double checking them. Does not include calculating advancing/rankings/records. Those will be follow up PRs (which I have already done, but I want to add tests).

Have not checked if I deleted everything related to those features, will do after dinner.

Comment on lines 42 to 52
new_attempts = results.map.with_index(1) do |r, i|
same_result = previous_attempts.find_by(result: r, attempt_number: i)
if same_result.present?
same_result
else
different_result = previous_attempts.find_by(attempt_number: i)
new_result = LiveAttempt.build(result: r, attempt_number: i)
different_result&.update(replaced_by_id: new_result.id)
new_result
end
end
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Note to self: I have a hunch there might be an even more efficient way to handle this.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Will play around later when I have more headspace.

Comment on lines 81 to 85
useEffect(() => {
if (results) {
setAttempts(results[currentIndex].attempts.map((a) => a.result));
}
}, [currentIndex, results]);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is the query ever re-fetched? i.e. Does results ever change? If not, then you indeed do need a side effect to set attempts when the data first loads, but you could explicitly update attempts when the "<" or ">" button is clicked instead of it being a side effect of the index changing. That would minimize the use of effects (even though it's the same number of useEffects, that effect would only be happening once).

@gregorbg gregorbg merged commit 95c89ec into thewca:main Feb 12, 2025
2 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants